package cn.itcast.springbook.interceptor;

/**
 * @author 21195
 * @version v1.0
 * @package cn.itcast.springbook.interceptor
 * @description:
 * @date 2019/6/13 16:34
 **/

import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 定义一个拦截器
 */
@Slf4j
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,Object handler) {
        log.debug("preHandle is run !");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView){
        log.debug("postHandle is run !");
    }

    @Override
    public void afterCompletion(HttpServletRequest request,HttpServletResponse response,Object handler,@Nullable Exception ex){
        log.debug("afterCompletion is run !");
    }
}
